Add better handling of deprecated configs#20565
Conversation
| warning = ("The '{key}' option (with value '{value}') is deprecated," | ||
| " please remove it from your configuration.") | ||
|
|
||
| def check_for_invalid_version(value: Optional[str]): |
There was a problem hiding this comment.
At some point, it may be worth pulling this out of an inner function and making it a decorator that could be used in other things besides configuration expiration.
|
I added some fairly extensive unit tests (and fixed a couple of bugs along the way). I also added some documentation explaining the behavior. As far as I can tell, this is good to go. |
|
@balloob @MartinHjelmare all comments have been addressed, is there anything else you'd like to see changed or do you think this is ready to go? It'd be nice to have available with 0.87 so that we can start cleaning up some things. |
|
Would anything benefit in 0.87? I think we should just merge to dev when it's ready without tagging. |
28541a3 to
d0ebafc
Compare
|
My thinking is that it would give us the starting version to use to deprecate things at, but you're right, we could start that with the next version. |
|
I prefer the next version because we just had a pretty rocky release. |
MartinHjelmare
left a comment
There was a problem hiding this comment.
Now I've read through everything finally. Some more comments below.
f1eefd0 to
5de4766
Compare
|
Rebased and cleaned up merged conflicts. @MartinHjelmare @balloob any further concerns with this? |
|
This is great! |
Description:
Allow the ability to deprecate specific configuration keys with optional replacements and optional invalidation dates to make less breaking changes. Here's how it works:
cv.deprecatednow takes additional parametersreplacement_key,invalidation_version,defaultinvalidation_versionand if not raises a warning indicating what the replacement key to use is.invalidation_versionit raisesvol.Invalidwith the same message indicating how to resolve the problem.I've demonstrated with the
update_intervalconfiguration key being replaced with thescan_intervalconfiguration key in the freedns component.This needs a few more tests before this can be merged. A good next step would be to surface this in the UI.
Related issue (if applicable): Spawned from discussion in #20526.
Checklist:
tox. Your PR cannot be merged unless tests passIf the code does not interact with devices: